package com.huanuo.internetofthings.controller.enterpriseCustom;

import com.huanuo.internetofthings.bo.enterpriseCustom.EnterpriseCustom;
import com.huanuo.internetofthings.service.enterpriseCustom.EnterpriseCustomService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.unicorn.framework.core.ResponseDto;
import org.unicorn.framework.core.SysCode;
import org.unicorn.framework.core.exception.PendingException;

import java.util.List;

/**
 * <p>
 * 设备客户表 前端控制器
 * </p>
 *
 * @author xiebin
 * @since 2018-07-25
 */
@RestController
@RequestMapping("/enterpriseCustom")
@Api(value = "设备客户模块", tags = { "设备客户模块" })
public class EnterpriseCustomController {
	@Autowired
    private EnterpriseCustomService enterpriseCustomService;
	
	/**
     * 用户查询职责范围内设备列表
     * @return
     * @throws PendingException
     */
	@ApiOperation("用户查询职责范围内设备列表")
	@RequestMapping(value = { "/list/{deviceNo}" }, method = { RequestMethod.GET })
	public ResponseDto<List<EnterpriseCustom>> page(@PathVariable("deviceNo") String deviceNo) throws PendingException {
		if(StringUtils.isBlank(deviceNo)){
			throw new PendingException(SysCode.PARA_NULL,"设备编号不能为空");
		}
		EnterpriseCustom enterpriseCustom= new EnterpriseCustom();
		enterpriseCustom.setDeviceNo(deviceNo);
		return new ResponseDto<>(enterpriseCustomService.selectList(enterpriseCustom));
	}
}
